<?php

$CentreName = $_REQUEST['CentreName'];
$Address = $_REQUEST['Address'];
$PostalCode = $_REQUEST['PostalCode'];

include 'conn.php';

$sql = "insert into centre(CentreName,Address,PostalCode) values('$CentreName','$Address','$PostalCode')";
$result = @mysql_query($sql);
if ($result){
    $get = mysql_query("Select CentreId from Centre where CentreName='$CentreName'");
    while($row=  mysql_fetch_array($get))
    {
        $centreId = $row['CentreId'];
    }
    $todayEndDate = date('Y-m-t', strtotime(date('d-m-Y')));
    $sql1 = mysql_query("insert into tracking(CentreId, Date,Status)VALUES($centreId,'$todayEndDate','Not Exported')");
    
	echo json_encode(array('success'=>true));
} else {
	echo json_encode(array('msg'=>'Some errors occured.'));
}
?>